<template>
	<view>
		<view>
			<button @click="gotoAddClassPage()">加入班级</button>
		</view>
		<view>
			 <view v-for="(item,i) in classes" :key="i">
				 <text @click="gotoClassMessage(item.foreClassMessages,item.id)">
					 \n
					 &nbsp;&nbsp;&nbsp;{{item.name}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;未读消息: {{item.count}}
					 <text style="color: #999999;">——————————————————————————————</text>
				 </text>
			 </view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				classes:{}
			}
		},
		onShow() {
			var userId=uni.getStorageSync("user").id;
			uni.request({
			method:"GET",
			url:this.requestUrl+"/ForeClass/myClasses?userId="+userId,
			success:response=>{
				this.classes=response.data;
			}	
			})
		}
		,
		methods: {
			gotoClassMessage(classMessages,classId){
                	uni.setStorageSync("currentClassMessages",classMessages);
					uni.setStorageSync("currentClassId",classId);
					uni.navigateTo({url:'../classMessage/classMessage'});
			},
			gotoAddClassPage(){
				uni.navigateTo({url:'../addClass/addClass'});
			}
		}
	}
</script>

<style>

</style>
